-
Notifications
You must be signed in to change notification settings - Fork 473
Return IPopupResult from PopupExtensions.ClosePopupAsync()
#2677
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Return IPopupResult from PopupExtensions.ClosePopupAsync()
#2677
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR changes the ClosePopupAsync API to return an IPopupResult (and a generic IPopupResult<T>) instead of void, adds generic overloads, and centralizes popup close logic into PopupExtensions.shared.cs.
- Changed
PopupService.ClosePopupAsyncmethods to forward to new extension methods - Added
ClosePopupAsyncandClosePopupAsync<TResult>inPopupExtensions.shared.cs - Removed internal
GetCurrentPopupPageand unified modal‐stack lookup
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| src/CommunityToolkit.Maui/Services/PopupService.shared.cs | Delegated existing close logic to navigation extension methods |
| src/CommunityToolkit.Maui/Extensions/PopupExtensions.shared.cs | Added new ClosePopupAsync overloads returning IPopupResult types |
| src/CommunityToolkit.Maui.UnitTests/Extensions/PopupExtensionsTests.cs | Added tests for the new close‐with‐result APIs |
Comments suppressed due to low confidence (1)
src/CommunityToolkit.Maui.UnitTests/Extensions/PopupExtensionsTests.cs:1280
- Consider adding a test for the case where no popup is present (e.g. verify that calling
ClosePopupAsyncthrowsPopupNotFoundException).
[Fact(Timeout = (int)TestDuration.Short)]
src/CommunityToolkit.Maui.UnitTests/Extensions/PopupExtensionsTests.cs
Outdated
Show resolved
Hide resolved
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…Tests.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR changes ClosePopupAsync to return IPopupResult (and a generic IPopupResult<T>), delegates the popup-close logic in PopupService to these extensions, and centralizes popup retrieval in GetMostRecentPopupPage.
- Return types for all
ClosePopupAsyncmethods updated to includeIPopupResult. - Added generic
ClosePopupAsync<T>overloads. - Consolidated popup lookup into
GetMostRecentPopupPageand updated tests accordingly.
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/CommunityToolkit.Maui/Services/PopupService.shared.cs | Simplified ClosePopupAsync methods to delegate to the updated extensions. |
| src/CommunityToolkit.Maui/Extensions/PopupExtensions.shared.cs | Changed methods to return IPopupResult/IPopupResult<T>, refactored popup-close logic. |
| src/CommunityToolkit.Maui.UnitTests/Extensions/PopupExtensionsTests.cs | Added tests for the new return values on page and navigation-based ClosePopupAsync. |
Comments suppressed due to low confidence (1)
src/CommunityToolkit.Maui/Extensions/PopupExtensions.shared.cs:270
- There’s no unit test for the scenario when no popup is present and
GetMostRecentPopupPageshould throw (e.g.PopupNotFoundExceptionorPopupBlockedException). Consider adding a test for that error path.
static PopupPage GetMostRecentPopupPage(in INavigation navigation)
src/CommunityToolkit.Maui.UnitTests/Extensions/PopupExtensionsTests.cs
Outdated
Show resolved
Hide resolved
|
Thanks Pedro! 🙌 |
Description of Change
This PR updates the return type for
Task PopupExtensions.ClosePopupAsync()->Task<IPopupResult> PopupExtensions.ClosePopupAsync().This PR also adds
Task<IPopupResult<T>> PopupExtensions.ClosePopupAsync<T>().PR Checklist
approved(bug) orChampioned(feature/proposal)mainat time of PRAdditional information
This PR also consolidates all of the Popup Open/Close logic to
PopupExtensions.shared.cs; e.g.PopupService.CloseAsync()now callsPopupExtensions.ClosePopupAsync().